Skip to content

Make project ID optional in the CLI#1

Merged
nishithatanukunuri merged 2 commits into
mainfrom
feat/optional-project-id
Jun 18, 2026
Merged

Make project ID optional in the CLI#1
nishithatanukunuri merged 2 commits into
mainfrom
feat/optional-project-id

Conversation

@nishithatanukunuri

@nishithatanukunuri nishithatanukunuri commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The ZeroGPU backend now derives the project from the API key, so the CLI no longer requires a project ID. Commands require only the API key and send x-project-id only when a project ID is configured; login no longer prompts for a project ID (pass --project-id only to pin a specific project).

Changes

  • src/commands/* (12 commands): guard on the API key alone (if (!apiKey)); include the x-project-id header only when getProjectId() returns a value (...(projectId ? { "x-project-id": projectId.projectId } : {})).
  • src/commands/login.ts: project ID is optional — validated and stored only when provided via --project-id; the mandatory prompt was removed.
  • Docs (README.md, docs/DOCUMENTATION.md, docs/ADDING_COMMANDS.md): mark the project ID optional and show the new request/auth pattern.

Notes

  • lib/auth.ts (getProjectId) and lib/config.ts already treated the project ID as optional — no change needed there.
  • Backward compatible: a configured ZEROGPU_PROJECT_ID / --project-id is still honored and forwarded.
  • Part of the coordinated "derive project from key" change across the ZeroGPU services.

Testing

  • tsc --noEmit clean, eslint . clean, vitest green (24 tests).

Summary by CodeRabbit

  • Documentation

    • Updated login and command documentation to reflect new credential handling behavior.
  • New Features

    • Login now prompts only for API key (masked input); project ID is auto-derived or optionally pinned with --project-id.
    • All commands now require only an API key; project ID is optional and derived automatically when available.

The ZeroGPU backend now derives the project from the API key, so the CLI no
longer requires a project ID. Commands require only the API key and send
x-project-id only when a project ID is configured; login no longer prompts for
a project ID (pass --project-id only to pin a specific project).

- commands/*: guard on the API key alone; include x-project-id header only when
  getProjectId() returns a value.
- login: project ID is optional — validated and stored only when provided via
  --project-id; no longer prompted.
- docs (README, DOCUMENTATION, ADDING_COMMANDS) updated to mark the project ID
  optional and show the new request/auth pattern.
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: edf0570d-995f-4e8f-8baa-ad3abb20d1e5

📥 Commits

Reviewing files that changed from the base of the PR and between 8a0850e and 2db0ef7.

📒 Files selected for processing (1)
  • src/commands/login.ts
 __________________________________________________________________________________________________________________________
< Unix was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things. >
 --------------------------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
📝 Walkthrough

Walkthrough

All CLI commands are updated so only the API key is required for authentication. The login command now treats --project-id as optional, deriving the project from the API key by default and omitting it from saved config when not supplied. Every API-calling command drops its projectId preflight requirement and conditionally includes the x-project-id request header only when a project ID is present. Documentation is updated accordingly.

Changes

Optional Project ID Across CLI

Layer / File(s) Summary
Login command: optional project ID flow
src/commands/login.ts
Removes promptPlain import; browser-open trigger fires only on missing API key; --project-id is validated and persisted only when explicitly provided, otherwise omitted from saved config entirely.
All commands: API-key-only preflight and conditional x-project-id header
src/commands/chat.ts, src/commands/chatThinking.ts, src/commands/classifyIab.ts, src/commands/classifyIabEnriched.ts, src/commands/classifyStructured.ts, src/commands/classifyZeroShot.ts, src/commands/extractEntities.ts, src/commands/extractJson.ts, src/commands/extractPii.ts, src/commands/generateFollowups.ts, src/commands/redactPii.ts, src/commands/summarize.ts
Each command's preflight guard is narrowed from !apiKey || !projectId to !apiKey only, with error messages updated accordingly; the x-project-id request header is conditionally spread in only when projectId is present.
Documentation: reflect optional project ID
README.md, docs/ADDING_COMMANDS.md, docs/DOCUMENTATION.md
ZEROGPU_PROJECT_ID is marked optional in the env var table; login examples and --project-id description are revised; x-project-id header noted as optional in the API contract; troubleshooting entry no longer lists project ID as required.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop, hop, the project ID is free,
No longer required to unlock the key!
Just bring your API key to the gate,
The project will follow — no need to wait.
One credential rules, the rest derive,
And x-project-id sends only when alive! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Make project ID optional in the CLI' directly and clearly summarizes the main change—making project ID optional across the CLI. It matches the PR objectives perfectly.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/optional-project-id

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/login.ts`:
- Around line 104-109: When the login command is executed without the
--project-id flag, the existing projectId should be cleared from the config
rather than retained. In the writeConfig call within the login command, modify
the spread of existing config to explicitly remove or override the projectId
field so that when projectId is not provided (undefined), it is either set to
null or excluded entirely from the final config object. This ensures that old
projectId values are not retained when users run login without specifying a
project ID.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7154c5f3-b82d-4295-8213-ab4e9e0e8261

📥 Commits

Reviewing files that changed from the base of the PR and between 868d2b9 and 8a0850e.

📒 Files selected for processing (16)
  • README.md
  • docs/ADDING_COMMANDS.md
  • docs/DOCUMENTATION.md
  • src/commands/chat.ts
  • src/commands/chatThinking.ts
  • src/commands/classifyIab.ts
  • src/commands/classifyIabEnriched.ts
  • src/commands/classifyStructured.ts
  • src/commands/classifyZeroShot.ts
  • src/commands/extractEntities.ts
  • src/commands/extractJson.ts
  • src/commands/extractPii.ts
  • src/commands/generateFollowups.ts
  • src/commands/login.ts
  • src/commands/redactPii.ts
  • src/commands/summarize.ts

Comment thread src/commands/login.ts Outdated
Re-login without --project-id previously retained the old projectId via the
spread of the existing config, leaving a stale pin. Build the config explicitly
and remove projectId when none is provided, so login without it returns to the
unpinned (derive-from-key) state.
@nishithatanukunuri nishithatanukunuri merged commit dca4632 into main Jun 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant